Hello
I am able to generate successfully pdf but here is a problem with—
The PDFs produced by the system are locked. Why is PDF locked? Can we unlock this so that we can modify with Adobe writer?
Thanks
Waiting for ur reply
Hello
I am able to generate successfully pdf but here is a problem with—
The PDFs produced by the system are locked. Why is PDF locked? Can we unlock this so that we can modify with Adobe writer?
Thanks
Waiting for ur reply
Hi,
Can you please share some more details regarding the issue that you are facing, when you say "PDF files are locked"
If possible can you please share the code snippet that you are using to generate the PDF documents.
pdf.Author = "Copyright 2007 by T. Falcon Napier & Associates ";
pdf.Creator = "T. Falcon Napier & Associates - ChangeWorks!";
pdf.Keywords = "T. Falcon Napier & Associates, ChangeWorks, ChangeWorks!, ChangeGrid, Change, Grid";
pdf.Title = "ChangeWorks! ChangeGrid Survey " + lbl_SurveyName.Text;
pdf.Subject = pdf.Title;
pdf.Producer = pdf.Author;
security.IsAnnotationsModifyingAllowed = false;
security.IsContentsModifyingAllowed = false;
security.IsCopyingAllowed = false;
security.IsDocumentAssemblyingAllowed = false;
security.IsFormFillingAllowed = false;
pdf.Security = security;
pdf.DestinationType = DestinationType.Retain;
pdf.OpenType = OpenType.Auto;
Hello Nidhi,
The resultant PDF being generated at your end are getting locked because in your code you have set the security.IsContentsModifyingAllowed = false; which prevents the document to be modified after its created. Please set the value to true so that you can modify the document. In case you still face any problem, please let us know.
I set true that but there is no way to modify that.I m sending that i have generated through that.
Please tell me
Hello Nidhi,
Can you please share what sort of modifications you would like to make to the resultant PDF ?
Aspose.Pdf.Section sec1 = pdf.Sections.Add();
{ sec1.IsLandscape = true;
sec1.PageInfo.PageHeight = PageSize.LetterHeight;
sec1.PageInfo.PageWidth = PageSize.LetterWidth;
MarginInfo pageMargin = new MarginInfo();
pageMargin.Left = 15;
pageMargin.Top = 25;
sec1.PageInfo.Margin = pageMargin;
// sec1.IsNewPage = isNewPage;
} //Create the Page Header (for all pages) Aspose.Pdf.HeaderFooter header = new HeaderFooter(sec1);
string hdrColWidth = ((PageSize.LetterHeight - 150) / 2 - 25).ToString();
string colWidths = “150 " + hdrColWidth + " " + hdrColWidth + " " + hdrColWidth;
// 3 columns Aspose.Pdf.Table tblHeader = createPdfTable(“tblHeader”, 0, 0, colWidths, 0);
BorderInfo bi = new BorderInfo((int)BorderSide.Bottom, 1);
//Dim sysimgLogo As System.Drawing.Image = Drawing.Image.FromFile(Server.MapPath(”~/desktopmodules/changeworks/images/changeworks.jpg")) //Dim imgLogo As Aspose.Pdf.Image = New Aspose.Pdf.Image(sec1) //imgLogo = Aspose.Pdf.Image.FromSystemImage(sysimgLogo) Aspose.Pdf.Image imgLogo = new Aspose.Pdf.Image(sec1);
imgLogo.ImageInfo.File = Server.MapPath(“changeworks.gif”);
imgLogo.ImageScale = 1f;
//header.Paragraphs.Add(imgLogo) //row 1 of header Row row1Header = tblHeader.Rows.Add(); row1Header.VerticalAlignment = VerticalAlignmentType.Bottom; Cell cellLogo = row1Header.Cells.Add();
cellLogo.Paragraphs.Add(imgLogo); cellLogo.RowSpan = 3;
cellLogo.Border = bi;
//addTableRowCell(row1Header, “ChangeWorks!”, 14) // addTableRowCell(row1Header, "Prepared for: " + lblClientName.Text, 9);
addTableRowCell(row1Header, "Profile: " + lbl_SurveyName.Text, 14);
//row 2 of header Row row2Header = tblHeader.Rows.Add();
row2Header.VerticalAlignment = VerticalAlignmentType.Top;
//addTableRowCell(row2Header, “”, 9) //string clientHeading = lblClientEmail.Text + ", " + lblClientPhone.Text;
// addTableRowCell(row2Header, clientHeading, 9);
string profileHeading = "Practitioner: " + lbl_practname.Text + ", " + lbl_email.Text + ", " + lbl_phone.Text;
addTableRowCell(row2Header, profileHeading, 9); //row 3 of header Row row3Header = tblHeader.Rows.Add(); row3Header.VerticalAlignment = VerticalAlignmentType.Top; //addTableRowCell(row2Header, “”, 9) addTableRowCell(row3Header, "Prepared on: " + lbl_sentdate.Text, 9);
//addTableRowCell(row3Header, "Completed on: " + lbl_responsedate.Text, 9);
//add bottom border to heading cells foreach (Cell cell in row3Header.Cells) { cell.Border = bi;
} //finalize heading settings sec1.EvenHeader = header;
sec1.OddHeader = header;
header.Margin.Top = 25; header.Margin.Left = 15;
header.Paragraphs.Add(tblHeader);
//the CHANGE GRID image ! Aspose.Pdf.Image img = new Aspose.Pdf.Image(sec1); img.ImageInfo.ImageFileType = ImageFileType.Png;
//img.PositioningType = PositioningType.PageRelative //img.Top = 40 img.ImageScale = 1f; img.ZIndex = -1;
img.ImageInfo.ImageStream = ms;
//Individual Name nidhi if (ViewState[“indName”] != null) { Aspose.Pdf.Table pdfTab = new Aspose.Pdf.Table();
pdfTab.Margin.Top = 11; pdfTab.Margin.Left = 0; sec1.Paragraphs.Add(pdfTab); //Set with column widths of the table pdfTab.ColumnWidths = “120 160”;
TextInfo pdfTabTextInf = new TextInfo();
pdfTabTextInf.FontName = “Arial”;
pdfTabTextInf.FontSize = 12;
pdfTabTextInf.LineSpacing = 3;
pdfTabTextInf.Alignment = AlignmentType.Left;
pdfTab.DefaultCellTextInfo = pdfTabTextInf;
Row pdfRow1 = pdfTab.Rows.Add();
pdfRow1.Cells.Add(“Individual Name:”);
pdfRow1.Cells.Add(ViewState[“indName”].ToString());
} //end Aspose.Pdf.Table tbl = createPdfTable(“Activities Table”, 14, 0, “20 200 27 27 27”, 3);
//Activity List Heading row Row r = tbl.Rows.Add(); // addTableRowCell(r, “”, 9);
//no heading for Activity Number addTableRowCell(r, “Activities”, 13);
addTableRowCell(r, “A”, 8); addTableRowCell(r, “C”, 8); addTableRowCell(r, “I”, 8); // cw_PractCampaignResponseAnswerInfo info = default(cw_PractCampaignResponseAnswerInfo);
for (int i = (startActivityNumber - 1);
i <= (endActivityNumber - 1);
i++) { info = infos[i]; r = tbl.Rows.Add();
//determine row color based on importance level string rowColor = “Black”;
//Activity Number addTableRowCell(r, “#” + info.ActivityNumber.ToString(), “Arial”, 10, rowColor, AlignmentType.Right);
//Activity Name addTableRowCell(r, info.ShortDesc, “Arial”, 10, rowColor, AlignmentType.Left); //Ability Rating addTableRowCell(r, info.AbilityLevel.ToString(), “Arial”, 10, rowColor, AlignmentType.Left);
//Challenge Rating addTableRowCell(r, info.ChallengeLevel.ToString(), “Arial”, 10, rowColor, AlignmentType.Left);
//Importance Rating addTableRowCell(r, info.ImportanceLevel.ToString(), “Arial”, 10, rowColor, AlignmentType.Left);
} img.ID = “ChangeGrid”;
sec1.Paragraphs.Add(img);
sec1.Paragraphs[“ChangeGrid”].PositioningType = PositioningType.PageRelative; sec1.Paragraphs[“ChangeGrid”].Top = 65;
sec1.Paragraphs[“ChangeGrid”].Left = 275;
Text txtLegends = new Text(legendText);
TextInfo tiLegends = new TextInfo();
{ tiLegends.Alignment = AlignmentType.Center; tiLegends.FontName = “Arial”; tiLegends.FontSize = 9;
} txtLegends.TextInfo = tiLegends; txtLegends.TextWidth = 400; txtLegends.ID = “Legends”; sec1.Paragraphs.Add(txtLegends);
sec1.Paragraphs[“Legends”].PositioningType = PositioningType.PageRelative; sec1.Paragraphs[“Legends”].Top = 500; sec1.Paragraphs[“Legends”].Left = 350; sec1.Paragraphs.Add(tbl);
sec1.Paragraphs[“Activities Table”].Top = 25;
sec1.Paragraphs[“Activities Table”].Left = 35;
{ //add the generated ChangeGrid .png image // // Aspose.Pdf.HeaderFooter footer = new HeaderFooter(sec1);
string ftrColWidth = ((PageSize.LetterHeight) / 2 - 25).ToString(); string ftrColWidths = “100” + " " + (PageSize.LetterHeight - 165).ToString();
Aspose.Pdf.Table tblFooter = createPdfTable(“tblFooter”, 0, 0, ftrColWidths, 0); Row row1Footer = tblFooter.Rows.Add();
// addTableRowCell(row1Footer, “page $p of $P”, 9);
addTableRowCell(row1Footer, "Printed: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " – " + "Copyright 2006-2007. All Rights Reserved. T. Falcon Napier & Associates, Inc. " + “704-987-6500, www.changegrid.com”, 8, AlignmentType.Right); bi = new BorderInfo((int)BorderSide.Top, 1);
foreach (Cell cell in row1Footer.Cells) { cell.Border = bi;
} // sec1.EvenFooter = footer;
sec1.OddFooter = footer;
footer.Margin.Left = 600;
footer.Margin.Bottom = 25;
footer.Paragraphs.Add(tblFooter);
}
Hello Nidhi,
Thanks for sharing the resource files.
I've gone through the code snippet and I've tried creating a PDF document using it and I'm unable to notice the problem. In fact, in the code snippet I don't see any code line to set the security restriction over the resultant PDF document. From the resultant PDF that I've generated, I'm able to copy the Text and Image successfully.
PS, I'm not sure about the implementation of methods addTableRowCell,createPdfTable so I've simply commented out these methods, and I believe in these methods there might not be any code to apply any security restrictions over the document.