Created
September 15, 2020 05:11
-
-
Save kenjiuno/df942d7cecb96dd826862dc2829e4241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
namespace Test.Utils | |
{ | |
public static class DefinitivePDF | |
{ | |
public static Stream FromFile(string file) | |
{ | |
var enc = Encoding.GetEncoding("latin1"); | |
var text = File.ReadAllText(file, enc); | |
text = Regex.Replace(text, "/CreationDate\\([^\\)]+\\)", "/CreationDate(D:20000101000000+00'00')"); | |
text = Regex.Replace(text, "/ModDate\\([^\\)]+\\)", "/ModDate(D:20000101000000+00'00')"); | |
text = Regex.Replace(text, "/ID\\s+\\[<[^\\>]+><[^\\>]+>\\]", "/ID [<123><456>]"); | |
return new MemoryStream(enc.GetBytes(text)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment