Copy link to clipboard
Copied
Hi,
I have a script to export PDF to PNG. While exporting the PNG the png is exported and a thin line appeared in the output as well as text blured.
Is there any way to overcome the hairline and text blur.
app.preferences.rulerUnits = Units.PIXELS;
app.displayDialogs = DialogModes.NO;
var fileRef = new File("D:/Cover/settings.csf");
loadColorSettings(fileRef);
fileRef = new File("D:/Cover/input.pdf");
var pdfOpenOptions = new PDFOpenOptions();
var resolution = 72;
pdfOpenOptions.antiAlias = true;
pdfOpenOptions.mode = OpenDocumentMode.RGB;
pdfOpenOptions.resolution = resolution;
pdfOpenOptions.page = 1;
pdfOpenOptions.cropPage = CropToType.BLEEDBOX;
pdfOpenOptions.constrainProportions = false;
pdfOpenOptions.bitsPerChannel = BitsPerChannelType.EIGHT;
var outerBorderColor = new SolidColor();
outerBorderColor.rgb.red = 0;
outerBorderColor.rgb.green = 0;
outerBorderColor.rgb.blue = 0;
var saveOptions = new ExportOptionsSaveForWeb();
saveOptions.format = SaveDocumentType.PNG;
saveOptions.PNG8 = false;
saveOptions.quality = 60;
saveOptions.blur = 0.0;
saveOptions.includeProfile = true;
saveOptions.embedColorProfile = true;
saveOptions.interlaced = false;
saveOptions.optimized = true;
saveOptions.colorConversion = false;
var doc = app.open(fileRef, pdfOpenOptions);
doc.trim(TrimType.BOTTOMRIGHT, true, false, true, false);
var docwidth = doc.width;
var docheight = doc.height;
doc.resizeImage(docwidth,docheight,resolution,ResampleMethod.BICUBIC);
app.displayDialogs = DialogModes.ERROR;
doc.flatten();
doc.selection.selectAll();
var saveFile = new File("D:/Cover/output.png");
doc.exportDocument(saveFile,ExportType.SAVEFORWEB,saveOptions);
doc.close(SaveOptions.DONOTSAVECHANGES);
app.displayDialogs = DialogModes.ERROR;
function loadColorSettings(file)
{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putProperty( charIDToTypeID('Prpr'), stringIDToTypeID('colorSettings') );
ref.putEnumerated( charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
var fileDesc = new ActionDescriptor();
fileDesc.putPath( charIDToTypeID('Usng'), file );
desc.putObject( charIDToTypeID('T '), stringIDToTypeID('colorSettings'), fileDesc );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
}
Thanks
Jayaraj
Copy link to clipboard
Copied
But why not use this method instead of doc.exportDocument() ?
var png_options = new PNGSaveOptions();
with (png_options)
{
compression = 9;
interlaced = false;
}
//app.displayDialogs = DialogModes.NO;
doc.saveAs(saveFile, png_options);
Copy link to clipboard
Copied
Yes, I did but the issue is the text uses drop shadowed and as a result it reflect in CS6 versions either PDF/Photoshop. How to supress the white line which is not appeared in earlier version and having the issue in CS6
Copy link to clipboard
Copied
Could you provide a simple PSD or screenshot to understand what's going on?
Copy link to clipboard
Copied
I have attached screenshot and the thin line around the text "Clinical Practice" and the bottom of the text highlighted in red. I cross checked pitstop and investigated that this might be occured due to the drop shadowed texted textframe. This is pdf document exported from Indesign document. As I am new to this forum not able to attach pdf for your understanding.

Copy link to clipboard
Copied
OK. You can download the PDF to GoogleDrive or another file sharing service and post link here.
P.S. I've never worked with PDF, but I'll try to figure it out. )
Copy link to clipboard
Copied
the meat of your script seems to be
Open page 1 of your pdf. This will open a new document with a single raster layer that may or may not contain transparency.
Trim the top and bottom of the page using the bottom right pixel
get new width which should not have changed
get new height which may have changed
resize to same size changing the doc resolution to 72.
dialog mode to error
flatten this is where you may be getting your white any transparent area would be filled with a white background color. If the trim did and antialiasing feathering to the top and botton edges some white may have been flatten into pixels less then 100% opaque. Try commenting out the flatten....
select all not needed
save a png that has no transparency because the document has been flatten to a background layer.
close
Find more inspiration, events, and resources on the new Adobe Community
Explore Now