Skip to content

Instantly share code, notes, and snippets.

@kenjiuno
Created September 15, 2020 05:11
Show Gist options
  • Save kenjiuno/df942d7cecb96dd826862dc2829e4241 to your computer and use it in GitHub Desktop.
Save kenjiuno/df942d7cecb96dd826862dc2829e4241 to your computer and use it in GitHub Desktop.
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