<?xml version="1.0"?>
<ownershipDocument>

    <schemaVersion>X0303</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2010-01-31</periodOfReport>

    <issuer>
        <issuerCik>0000102212</issuerCik>
        <issuerName>UNIVEST CORP OF PENNSYLVANIA</issuerName>
        <issuerTradingSymbol>UVSP</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001408846</rptOwnerCik>
            <rptOwnerName>HOCHSTETLER KENNETH D</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>318 HIGHLAND AVENUE</rptOwnerStreet1>
            <rptOwnerStreet2></rptOwnerStreet2>
            <rptOwnerCity>SOUDERTON</rptOwnerCity>
            <rptOwnerState>PA</rptOwnerState>
            <rptOwnerZipCode>18964</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>0</isDirector>
            <isOfficer>1</isOfficer>
            <isTenPercentOwner>0</isTenPercentOwner>
            <isOther>0</isOther>
            <officerTitle>Senior Executive VP</officerTitle>
        </reportingOwnerRelationship>
    </reportingOwner>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>COMMON</value>
            </securityTitle>
            <transactionDate>
                <value>2010-01-31</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>A</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>5223</value>
                    <footnoteId id="F1"/>
                </transactionShares>
                <transactionPricePerShare>
                    <value>0</value>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>A</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>20168.492</value>
                    <footnoteId id="F2"/>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeHolding>
            <securityTitle>
                <value>COMMON</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>20168.492</value>
                    <footnoteId id="F2"/>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value></value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">RESTRICTED STOCK AWARD; VESTED IN THREE (3) YEARS.</footnote>
        <footnote id="F2">DOES INCLUDE 2,031.492 SHARES ACQUIRED ON OR AFTER AUGUST 15, 1996 THROUGH THE DIVIDEND REINVESTMENT PLAN AND EMPLOYEE STOCK PURCHASE PLAN.</footnote>
        <footnote id="F3">DOES INCLUDE 10,158 SHARES OF RESTRICTED STOCK.</footnote>
    </footnotes>

    <remarks></remarks>

    <ownerSignature>
        <signatureName>Jeffrey M. Schweitzer</signatureName>
        <signatureDate>2010-02-02</signatureDate>
    </ownerSignature>
</ownershipDocument>
[{"type": "4", "sequence": "1", "filename": "edgar.xml", "description": "PRIMARY DOCUMENT", "secsgml_size_bytes": 4250}]
X0303
4
2010-01-31
0000102212
UNIVEST CORP OF PENNSYLVANIA
UVSP
0001408846
HOCHSTETLER KENNETH D
318 HIGHLAND AVENUE
SOUDERTON
PA
18964
0
1
0
0
Senior Executive VP
COMMON
2010-01-31
4
A
0
5223
0
A
20168.492
D
COMMON
20168.492
D
RESTRICTED STOCK AWARD; VESTED IN THREE (3) YEARS.
DOES INCLUDE 2,031.492 SHARES ACQUIRED ON OR AFTER AUGUST 15, 1996 THROUGH THE DIVIDEND REINVESTMENT PLAN AND EMPLOYEE STOCK PURCHASE PLAN.
DOES INCLUDE 10,158 SHARES OF RESTRICTED STOCK.
Jeffrey M. Schweitzer
2010-02-02