Sign UpSign Up   Sign InSign In Welcome Guest,
Live Chat Live Chat

Inserting large custom XMP data into an existing pdf as PdfA1B complient

Last post 03-24-2009, 11:30 PM by forever. 10 replies.
Sort Posts: Previous Next
  •  03-11-2009, 5:06 PM 169322

    Inserting large custom XMP data into an existing pdf as PdfA1B complient .NET

    I need to append a very large (up to 100 kb) custom property to the XMP block of an existing Pdf/A document.

    After downloading a trial version of the Pdf.Kit() product.  I tried the code below and nothing seemed to happen.  I assume this is a limitation on the trial software?  Also, the generated PDF lost the Pdf/A compliancy. 

    Using your product:  Can I accomplish this?  If so, what am I doing wrong?

     

    Thank you!

     

    private void AppendXmpBlock()

    {

    System.Collections.ArrayList keywordlist = new System.Collections.ArrayList();

    Aspose.Pdf.Kit.PdfXmpMetadata xmpMetaData = new Aspose.Pdf.Kit.PdfXmpMetadata();

    FileStream input = new FileStream(txtFileIn.Text,FileMode.Open);

    FileStream output = new FileStream(txtFileOut.Text, FileMode.Create);

    xmpMetaData.InputStream = input;

    xmpMetaData.OutputStream = output;

    Aspose.Pdf.Kit.XmpSchema xmp = new Aspose.Pdf.Kit.XmpSchema();

    string name = @"pdf:TroysTest";

    string vlu = BuildATag("Nickname",GetBigString(), keywordlist);

    xmp.AddUserProperty(name,vlu);

    xmpMetaData.AddXmpRdf(xmp);

    xmpMetaData.Save();

    input.Close();

    output.Close();

    }

    private string GetBigString()

    {

    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < 500; i++) sb.Append("0123456789");

    sb.Append("The End.");

    return sb.ToString();

    }

    string BuildATag(string tagName, string tagValue, System.Collections.ArrayList keywordList)

    {

    string startTag = string.Format("<{0}>", tagName);

    string endTag = string.Format("</{0}>", tagName);

    string aTag = startTag + tagValue + endTag + "\r\n";

    keywordList.Add(tagValue);

    return aTag;

    }

     
  •  03-11-2009, 8:25 PM 169344 in reply to 169322

    Re: Inserting large custom XMP data into an existing pdf as PdfA1B complient

    I sure hope you get a reply on this.  I've been trying to use this exact same sample code with no success.  Everything seems to work fine but no XMP added.  My fear is this doesn't work.

    Lets see if anyone replies!
     
  •  03-12-2009, 1:51 AM 169380 in reply to 169344

    Re: Inserting large custom XMP data into an existing pdf as PdfA1B complient

    Hi,

    Thank you very much for considering Aspose.

    I'm looking into the matter, and you'll be updated with the results the earliest possible.

    We appreciate your patience.

    Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  03-13-2009, 9:37 AM 169623 in reply to 169380

    Re: Inserting large custom XMP data into an existing pdf as PdfA1B complient

    Thank you for looking into this issue.  Can you please let us know if you have found the issue.  I am very anxious to have this work.

    Thanks!
     
  •  03-13-2009, 9:46 AM 169625 in reply to 169623

    Re: Inserting large custom XMP data into an existing pdf as PdfA1B complient

    Actually, we went with a different product.

     
  •  03-13-2009, 10:25 AM 169633 in reply to 169625

    Re: Inserting large custom XMP data into an existing pdf as PdfA1B complient

    Just curious - what did you choose?  If you don't mind me asking?
     
  •  03-13-2009, 10:32 AM 169634 in reply to 169633

    Re: Inserting large custom XMP data into an existing pdf as PdfA1B complient

    Probably not appropriate to list competitors here.  If you email me at thm92673@hotmail.com with your direct email, I would be willing to reply.
     
  •  03-13-2009, 11:07 AM 169644 in reply to 169634

    Re: Inserting large custom XMP data into an existing pdf as PdfA1B complient

    Hi,

    I am not able to reproduce the error, I use the following code with Aspose.Pdf.Kit 3.3.0. Could you please also share the pdf file with us?

    1//set XMP Metadata
    2public static void Test_PdfXmpMetadata()
    3        {
    4            string TestPath = @"E:\xmpMeta\";
    5            System.Collections.ArrayList keywordlist = new System.Collections.ArrayList();
    6 Aspose.Pdf.Kit.PdfXmpMetadata xmpMetaData = new Aspose.Pdf.Kit.PdfXmpMetadata();
    7            FileStream input = new FileStream(TestPath + "example1.pdf", FileMode.Open);
    8            FileStream output = new FileStream(TestPath + "out.pdf", FileMode.Create);
    9            xmpMetaData.InputStream = input;
    10            xmpMetaData.OutputStream = output;
    11            Aspose.Pdf.Kit.XmpSchema xmp = new Aspose.Pdf.Kit.XmpSchema();
    12            string name = @"pdf:TroysTest";
    13            string vlu = BuildATag("Nickname",GetBigString(), keywordlist);
    14            xmp.AddUserProperty(name,vlu);
    15            xmpMetaData.AddXmpRdf(xmp);
    16            xmpMetaData.Save();
    17            input.Close();
    18            output.Close();
    19        }

    20//get XMP Metadata
    21        public static void Test_PdfXmpMetadata_get(){
    22            string TestPath = @"E:\xmpMeta\";
    23            Aspose.Pdf.Kit.PdfXmpMetadata xmpMetaData = new Aspose.Pdf.Kit.PdfXmpMetadata();
    24            FileStream input = new FileStream(TestPath + "out.pdf", FileMode.Open);
    25            xmpMetaData.InputStream = input;
    26           byte [] tem= xmpMetaData.GetXmpMetadata();
    27           ASCIIEncoding encoding = new ASCIIEncoding();
    28           string constructedString = encoding.GetString(tem);
    29           Console.WriteLine(constructedString);
    30        }

    31        private static string GetBigString()
    32        {
    33            StringBuilder sb = new StringBuilder();
    34            for (int i = 0; i < 500; i++) sb.Append("0123456789");
    35            sb.Append("The End.");
    36            return sb.ToString();
    37        }

    38        static string BuildATag(string tagName, string tagValue, System.Collections.ArrayList keywordList)
    39        {
    40            string startTag = string.Format("<{0}>", tagName);
    41            string endTag = string.Format("</{0}>", tagName);
    42            string aTag = startTag + tagValue + endTag + "\r\n";
    43            keywordList.Add(tagValue);
    44            return aTag;
    45        }

    46


    Felix Liu
    Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  03-13-2009, 12:33 PM 169661 in reply to 169644

    Re: Inserting large custom XMP data into an existing pdf as PdfA1B complient

    Thanks for the reply, Felix.  Its very interesting what is going on here and hopefully it is an easy fix.  I agree that your program does appear to work.  Using this code to enter the metadata and then using this code to retrieve the metadata does return the information.  However, if you open the PDF in Adobe and view the Additional properties to see the XMP it is not there.  If you view the PDF in a text editor it seems the XMP data is added to the end of the file in such a way that it is not viewable through the PDF.  If you look at a file that has additional XMP data viewable through Adobe it is stored at the top of the raw PDF like this:

    %PDF-1.7
    %âãÏÓ
    1 0 obj
    <</Metadata 2 0 R/Pages 3 0 R/Type/Catalog/OutputIntents[26 0 R]>>
    endobj
    2 0 obj
    <</Length

    Is there a way to have your program enter this information the same way?

    Also, what is the correct syntax if we wanted to specify the XML namespace for this data to be stored like - xmlns:xmp="http://ns.adobe.com/xap/1.0/" so it shows in the "xmp core" area?

    Once again thanks for your time!
     
  •  03-15-2009, 4:08 PM 169793 in reply to 169661

    Re: Inserting large custom XMP data into an existing pdf as PdfA1B complient

    Hi,

    Thanks for the important information.

    I have received the PDF file and  logged the problem as PDFKITNET-7884 in our issue tracking system. We will investigate it in detail and then decide whether it could be supported in short time or not.

    Thanks,


    Felix Liu
    Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  03-24-2009, 11:30 PM 171369 in reply to 169322

    Re: Inserting large custom XMP data into an existing pdf as PdfA1B complient

    The issues you have found earlier (filed as 7884) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by forever.
     
View as RSS news feed in XML